package com.gillion.tms.school.student.mapper.impl;
import java.util.List;
import com.gfa4j.mybatis.dao.MyBatisDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import com.gfa4j.mybatis.dao.pojo.Page;
import com.gillion.tms.school.student.mapper.StudentMapper;
import com.gillion.tms.school.student.model.Student;
import com.gillion.tms.school.student.model.SelectStudentByNameParam;

@Component("studentMapperImpl")
public class StudentMapperImpl{
	
	@Autowired
	private MyBatisDao myBatisDao;
	
	
	public Page selectStudentByName(SelectStudentByNameParam params){
		 Page page = params.getPage();
	 page.setTotalRecord(this.countByStudentExample(params));
	 page.setRecords(this.studentList(params));
		 return page;
}

	private List<Student> studentList(SelectStudentByNameParam params){
	return  myBatisDao.getCustomSqlSession().selectList("com.gillion.tms.school.student.mapper.StudentMapper.selectStudentByName", params);
	}

	private int countByStudentExample(SelectStudentByNameParam params){
		return  myBatisDao.getCustomSqlSession().selectOne("com.gillion.tms.school.student.mapper.StudentMapper.countByStudentExample", params);
	}
	
		
}
